﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MengLin.OOP.DesignPattern.Responsibility
{
    /// <summary>
    /// 抽象审批人
    /// </summary>
    public abstract class AbstractManager
    {
        /// <summary>
        /// 下一个审批者
        /// </summary>
        private AbstractManager _abstractManager = null;

        /// <summary>
        /// 设置下一个审批者
        /// </summary>
        /// <param name="abstractManager"></param>
        public void SetNext(AbstractManager abstractManager)
        {
            _abstractManager = abstractManager;
        }

        /// <summary>
        /// 审批
        /// </summary>
        /// <param name="applyContext"></param>
        public abstract void Approval(ApplyContext applyContext);

        /// <summary>
        /// 审批人
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 传递给下一个审批人进行审批
        /// </summary>
        /// <param name="applyContext"></param>
        protected void ApprovalNext(ApplyContext applyContext)
        {
            if (_abstractManager != null)
            {
                _abstractManager.Approval(applyContext);
            }
        }
    }
}
